import { APP_INITIALIZER } from "@angular/core";
import { UniqueCodeConfigService } from "./unique-code-config.service";
import { FixedSegmentComponent } from "./fixed-segment.component";
import { SerialNumberSegmentComponent } from "./serial-number-segment.component";
import { TimeStampSegmentComponent } from "./time-stamp-segment.component";

export const BASICARCHIVES_UNIQUECODECONFIG_PROVIDERS = [
  { provide: APP_INITIALIZER, useFactory: initializeConfig, deps: [UniqueCodeConfigService], multi: true },
];

export function initializeConfig(uniqueCodeConfigService: UniqueCodeConfigService) {
  return () => {
    uniqueCodeConfigService.registerSegmentType('FixedSegment', FixedSegmentComponent);
    uniqueCodeConfigService.registerSegmentType('SerialNumberSegment', SerialNumberSegmentComponent);
    uniqueCodeConfigService.registerSegmentType('TimeStampSegment', TimeStampSegmentComponent);
  };
}
